namespace 软件文管理
{
    internal static class UIDispach
    {

        public static void ToLogin()
        {
            ClosePrevForm();
            currentForm = new Login();
        }

        public static void ToStart()
        {
            ClosePrevForm();
            currentForm = new Start();
        }


        public static void ToNewArticle()
        {
            ClosePrevForm();
            currentForm = new FormNewArticle();
        }


        public static void ToArticleSync()
        {
            ClosePrevForm();
            currentForm = new FormArticleSync();
        }


        public static void Exit()
        {
            ClosePrevForm();
            AppExit = true;
            Application.Exit();
        }


        public static void ClosePrevForm()
        {
            currentForm?.Close();
        }



        internal static void Run()
        {
            if (currentForm != null)
            {
                if (currentForm.IsDisposed)
                {
                    Exit();
                }
                else
                    Application.Run(currentForm);
            }
        }
        private static Form? currentForm = null;


        public static bool AppExit = false;
    }

}